package com.adminex.config;

import com.adminex.interceptor.LoginInterceptor;
import com.adminex.interceptor.RedisUrlCountIntrceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/*
mvc配置
 */
@Configuration
public class AdminExWebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private RedisUrlCountIntrceptor redisUrlCountIntrceptor;
    //配置拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                //拦截所有请求
                .addPathPatterns("/**")
                //放行指定请求
                .excludePathPatterns("/",
                        "/login",
                        "/css/**",
                        "/images/**",
                        "/fonts/**",
                        "/js/**");
        registry.addInterceptor(redisUrlCountIntrceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/css/**",
                        "/images/**",
                        "/fonts/**",
                        "/js/**");
    }
}
